home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / LIB / VERT_DRA.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  6.7 KB  |  174 lines

  1.  
  2. package sub_arctic.lib;
  3.  
  4. import sub_arctic.output.loaded_image;
  5. import sub_arctic.output.drawable;
  6. import sub_arctic.input.pressable;
  7. import sub_arctic.input.move_draggable;
  8. import sub_arctic.input.event;
  9. import sub_arctic.input.user_info_holder;
  10. import sub_arctic.input.pick_collector;
  11. import sub_arctic.input.callback_object;
  12. import java.awt.Point;
  13.  
  14. /** 
  15.  * This class provides a container for dragging that is limited to changes
  16.  * in y only.  You can put any subtree inside it to make that subtree 
  17.  * draggable.  The container handles the pick process correctly so that it 
  18.  * only initiates a drag if you actually click over an object inside the an 
  19.  * object in the sub-tree (not simply anywhere inside the bounds of the 
  20.  * container).  The container will "shrink-wrap" around the objects it 
  21.  * contains, and can optionally draw a bounding rectangle as drag feedback.
  22.  *
  23.  * @author Scott Hudson
  24.  */
  25. public class vert_drag_container extends drag_container {
  26.  
  27.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  28.  
  29.   /** 
  30.    * Full constructor.  
  31.    *
  32.    * @param int             x              initial x position of the container.
  33.    * @param int             y              initial y position of the container.
  34.    * @param boolean         do_bb_feedback whether we do bounding box feedback.
  35.    * @param callback_object cbo            object to make callbacks to.
  36.    */
  37.   public vert_drag_container(
  38.     int x, int y, boolean do_bb_feedback, callback_object cbo) 
  39. {
  40.       super(x,y,do_bb_feedback,cbo);
  41.     }
  42.  
  43.    //had:
  44.    //* @exception general
  45.  
  46.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  47.  
  48.   /** 
  49.    * Nearly full constructor.  This provides a null callback.
  50.    *
  51.    * @param int     x              initial x position of the container.
  52.    * @param int     y              initial y position of the container.
  53.    * @param boolean do_bb_feedback whether we do bounding box feedback.
  54.    */
  55.   public vert_drag_container(int x, int y, boolean do_bb_feedback) 
  56. {
  57.       super(x,y,do_bb_feedback);
  58.     }
  59.  
  60.    //had:
  61.    //* @exception general
  62.  
  63.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  64.  
  65.   /** 
  66.    * Handle the start of a drag to the object.  
  67.    * @param event evt   the event "causing" the start of the drag.
  68.    * @param int    x_pos     x position of new position (in parent's coords).
  69.    * @param int    y_pos     y position of new position (in parent's coords).
  70.    * @param int    grab_x    x position where we started the drag (in local 
  71.    *                         coords).
  72.    * @param int    grab_y    y position where we started the drag (in local 
  73.    *                         coords).
  74.    * @param Object user_info information provided when this object requested 
  75.    *                         focus.
  76.    * @return boolean indicating whether the input was consumed (in this case it
  77.    *                 always is).
  78.    */
  79.   public boolean drag_start(
  80.     event evt, 
  81.     int x_pos, int y_pos, 
  82.     int grab_x, int grab_y, 
  83.     Object user_info)
  84.     {
  85.       /* modify the move so there is no x component, then let super class go */
  86.       return super.drag_start(evt, x(), y_pos, grab_x, grab_y, user_info);
  87.     }
  88.  
  89.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  90.  
  91.   /** 
  92.    * Handle a movement during a drag.  Here we just set our position to 
  93.    * follow the event location and do the move callback. 
  94.    *
  95.    * @param event evt   the event "causing" the start of the drag.
  96.    * @param int    x_pos     x position of new position (in parent's coords).
  97.    * @param int    y_pos     y position of new position (in parent's coords).
  98.    * @param int    start_x   x position where we started the drag (in parent's
  99.    *                         coords).
  100.    * @param int    start_y   y position where we started the drag (in parent's
  101.    *                         coords).
  102.    * @param int    grab_x    x position where we started the grab (in local 
  103.    *                         coords).
  104.    * @param int    grab_y    y position where we started the grab (in local 
  105.    *                         coords).
  106.    * @param Object user_info information provided when this object requested 
  107.    *                         focus.
  108.    * @return boolean indicating whether the input was consumed (in this case it
  109.    *                 always is).
  110.    */
  111.   public boolean drag_feedback(
  112.     event evt, 
  113.     int x_pos, int y_pos, 
  114.     int st_x, int st_y, 
  115.     int grab_x, int grab_y, 
  116.     Object user_info)
  117.     {
  118.       /* modify the move so there is no y component, then let super class go */
  119.       return super.drag_feedback(evt, x(), y_pos, st_x, st_y, grab_x, grab_y, 
  120.                                    user_info);
  121.     }
  122.  
  123.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  124.  
  125.   /** 
  126.    * Handle input corresponding to the end of a drag.  
  127.    *
  128.    * @param event evt   the event "causing" the start of the drag.
  129.    * @param int    x_pos     x position of new position (in parent's coords).
  130.    * @param int    y_pos     y position of new position (in parent's coords).
  131.    * @param int    start_x   x position where we started the drag (in parent's
  132.    *                         coords).
  133.    * @param int    start_y   y position where we started the drag (in parent's
  134.    *                         coords).
  135.    * @param int    grab_x    x position where we started the grab (in local 
  136.    *                         coords).
  137.    * @param int    grab_y    y position where we started the grab (in local 
  138.    *                         coords).
  139.    * @param Object user_info information provided when this object requested 
  140.    *                         focus.
  141.    * @return boolean indicating whether the input was consumed (in this case it
  142.    *                 always is).
  143.    */
  144.   public boolean drag_end(
  145.     event evt, 
  146.     int x_pos, int y_pos, 
  147.     int st_x, int st_y, 
  148.     int grab_x, int grab_y, 
  149.     Object user_info)
  150.     {
  151.       /* modify the move so there is no y component, then let super class go */
  152.       return super.drag_end(evt, x(), y_pos, st_x, st_y, grab_x, grab_y, 
  153.                                    user_info);
  154.     }
  155.  
  156.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  157. }
  158. /*=========================== COPYRIGHT NOTICE ===========================
  159.  
  160. This file is part of the subArctic user interface toolkit.
  161.  
  162. Copyright (c) 1996 Scott Hudson and Ian Smith
  163. All rights reserved.
  164.  
  165. The subArctic system is freely available for most uses under the terms
  166. and conditions described in 
  167.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  168. and appearing in full in the lib/interactor.java source file.
  169.  
  170. The current release and additional information about this software can be 
  171. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  172.  
  173. ========================================================================*/
  174.